package com.ktgj.customer.controller;

import java.util.List;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ktgj.common.log.annotation.Log;
import com.ktgj.common.log.enums.BusinessType;
import com.ktgj.common.security.annotation.PreAuthorize;
import com.ktgj.customer.domain.TravelItineraryPicture;
import com.ktgj.customer.service.ITravelItineraryPictureService;
import com.ktgj.common.core.web.controller.BaseController;
import com.ktgj.common.core.web.domain.AjaxResult;
import com.ktgj.common.core.utils.poi.ExcelUtil;
import com.ktgj.common.core.web.page.TableDataInfo;

/**
 * 行程详情图片Controller
 * 
 * @author ruoyi
 * @date 2022-01-13
 */
@RestController
@RequestMapping("/picture")
public class TravelItineraryPictureController extends BaseController
{
    @Autowired
    private ITravelItineraryPictureService travelItineraryPictureService;

    /**
     * 查询行程详情图片列表
     */
    @PreAuthorize(hasPermi = "customer:picture:list")
    @GetMapping("/list")
    public TableDataInfo list(TravelItineraryPicture travelItineraryPicture)
    {
        startPage();
        List<TravelItineraryPicture> list = travelItineraryPictureService.selectTravelItineraryPictureList(travelItineraryPicture);
        return getDataTable(list);
    }

    /**
     * 导出行程详情图片列表
     */
    @PreAuthorize(hasPermi = "customer:picture:export")
    @Log(title = "行程详情图片", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, TravelItineraryPicture travelItineraryPicture) throws IOException
    {
        List<TravelItineraryPicture> list = travelItineraryPictureService.selectTravelItineraryPictureList(travelItineraryPicture);
        ExcelUtil<TravelItineraryPicture> util = new ExcelUtil<TravelItineraryPicture>(TravelItineraryPicture.class);
        util.exportExcel(response, list, "行程详情图片数据");
    }

    /**
     * 获取行程详情图片详细信息
     */
    @PreAuthorize(hasPermi = "customer:picture:query")
    @GetMapping(value = "/{travelItineraryPictureId}")
    public AjaxResult getInfo(@PathVariable("travelItineraryPictureId") Long travelItineraryPictureId)
    {
        return AjaxResult.success(travelItineraryPictureService.selectTravelItineraryPictureById(travelItineraryPictureId));
    }

    /**
     * 新增行程详情图片
     */
    @PreAuthorize(hasPermi = "customer:picture:add")
    @Log(title = "行程详情图片", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TravelItineraryPicture travelItineraryPicture)
    {
        return toAjax(travelItineraryPictureService.insertTravelItineraryPicture(travelItineraryPicture));
    }

    /**
     * 修改行程详情图片
     */
    @PreAuthorize(hasPermi = "customer:picture:edit")
    @Log(title = "行程详情图片", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TravelItineraryPicture travelItineraryPicture)
    {
        return toAjax(travelItineraryPictureService.updateTravelItineraryPicture(travelItineraryPicture));
    }

    /**
     * 删除行程详情图片
     */
    @PreAuthorize(hasPermi = "customer:picture:remove")
    @Log(title = "行程详情图片", businessType = BusinessType.DELETE)
	@DeleteMapping("/{travelItineraryPictureIds}")
    public AjaxResult remove(@PathVariable Long[] travelItineraryPictureIds)
    {
        return toAjax(travelItineraryPictureService.deleteTravelItineraryPictureByIds(travelItineraryPictureIds));
    }
}
